--[[
--
--   crab
--
--]]

crb = CreateFrame("Frame","crb",UIParent)

function crb:RegisterActionBar(actionbar)
local ab = {}
if actionbar.static == false then
 ab = CreateFrame("Frame","crab_"..actionbar.name,UIParent,"SecureStateHeaderTemplate")
else
 ab = CreateFrame("Frame","crab_"..actionbar.name,UIParent)
end
 ab:SetWidth(actionbar.buttons * actionbar.buttonsize)
 ab:SetHeight(actionbar.buttonsize)

 for i=1,actionbar.buttons do
  local actionbutton = CreateFrame("CheckButton","crab_"..actionbar.name.."_button"..i,UIParent,"ActionbarButtonTemplate")
  actionbutton:SetWidth(36)
  actionbutton:SetHeight(36)
  actionbutton:SetScale(actionbar.buttonsize/36)
  actionbutton:SetAttribute("newstate","1-2")
  actionbutton:SetAttribute("state","1")
  actionbutton:SetAttribute("statebutton","1:S1;2:S2")
  if type(actionbar.id[i]) ~= "string" then
  actionbutton:SetAttribute("type","action")

  actionbutton:SetAttribute("*action-S1",tonumber(actionbar.id[i]))
  actionbutton:SetAttribute("*action-S2",tonumber(actionbar.id[i])+2)
 
  actionbutton:SetID(actionbar.id[i])
  actionbutton.action = actionbar.id[i]
  getglobal(actionbutton:GetName().."Icon"):SetTexture(GetActionTexture(actionbar.id[i]))
  else
  actionbutton:SetAttribute("type","spell")
  actionbutton:SetAttribute("spell",actionbar.id[i])
  getglobal(actionbutton:GetName().."Icon"):SetTexture(GetSpellTexture(actionbar.id[i]))
  
  end
  if i > 1 then
  if actionbar.vspacing == nil then actionbar.vspacing = 8; end
  actionbutton:SetPoint("LEFT",getglobal("crab_"..actionbar.name.."_button"..i-1),"RIGHT",tonumber(actionbar.vspacing),0)
  else
  actionbutton:SetPoint("LEFT",getglobal("crab_"..actionbar.name),"LEFT",0,0)
  end

  ab:SetAttribute("addChild",actionbutton)
  end
 ab:SetPoint(actionbar.point[1], getglobal(actionbar.point[2]), actionbar.point[3], tonumber(actionbar.point[4]), tonumber(actionbar.point[5]))
 
end 
